<?php
namespace Home\Controller;
use Think\Controller;
class CommandController extends Controller {
    public function index(){
    	$this->display();
    }
    public function getCommandList(){
    	$res = D('command')->getCommandList();
    	if(!$res){
    		return ajaxReturn(0,'获取失败');
    	}
    	return ajaxReturn(1,'获取成功',$res);
    }
    public function insert(){
    	$this->display();
    }
    public function insertCommandInfo(){
    	if(!isset($_POST['command_name']) || !$_POST['command_name']){
    		return ajaxReturn(0,'传参失败');
    	}
    	$res = D('command')->insertCommandInfo($_POST);
    	if(!$res){
    		return ajaxReturn(0,'添加失败');
    	}
    	return ajaxReturn(1,'添加成功');
    }
    public function revise(){
    	if(!isset($_GET['command_id']) || !$_GET['command_id']){
    		return ajaxReturn(0,'传参失败');
    	}
    	$res = D('command')->getCommandInfo($_GET);
    	if(!$res){
    		return ajaxReturn(0,'添加失败');
    	}
    	$this->assign('command',$res);
    	$this->display();
    }
    public function reviseCommandInfo(){
    	if(!isset($_POST) || !$_POST){
    		return ajaxReturn(0,'传参失败');
    	}
    	$cond['command_id'] = $_POST['command_id'];
    	$data['command_name'] = $_POST['command_name'];
    	$data['command_value'] = $_POST['command_value'];
    	$res = D('command')->reviseCommandInfo($cond,$data);
    	if($res === false){
    		return ajaxReturn(0,'修改失败');
    	}
    	return ajaxReturn(1,'修改成功');
    }
}